#!/bin/sh

# Set perms on files that need to change from install.
chmod 644 /etc/lighttpd/conf-available/20-operate.conf
chmod 755 /var/www/html/operate/operate.py

# Activate thing-frontend fastcgi module.
cd /etc/lighttpd/conf-enabled
ln -s ../conf-available/20-operate.conf .

# Disable Apache, bonscript and cloud9
echo "Disabling Apache web service"
systemctl stop apache2.service
systemctl disable apache2.service
echo "Disabling bonescript service"
systemctl stop bonescript.socket
systemctl disable bonescript.socket
systemctl stop bonescript-autorun.service
systemctl disable bonescript-autorun.service
systemctl stop bonescript.service
systemctl disable bonescript.service
echo "Disabling cloud9 IDE service"
systemctl stop cloud9.socket
systemctl disable cloud9.socket
systemctl stop cloud9.service
systemctl disable cloud9.service

echo "Restarting lighttpd service"
systemctl restart lighttpd.service
set -x
systemctl status lighttpd.service
set +x

echo "Updating permissions /etc/redeem so thing-frontend can create config files"
chgrp www-data /etc/redeem
chmod 775 /etc/redeem
